home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / winsock / wschesb1.zip / SRC / COLOR.C < prev    next >
C/C++ Source or Header  |  1994-03-15  |  4KB  |  140 lines

  1. /*
  2.   C source for Winsock Chess
  3.   
  4.   Revision 1994-03-15
  5.   Modified by Donald Munro for use as a 2 player chess game over a 
  6.   WINSOCK layer on a TCP (or other WinSock supporting) network.
  7.   Source code and make files for MS Visual C/C++ V1.00/1.50.
  8.   February/March 1994
  9.   All GNU copyright and distribution conditions as described below and in the
  10.   file COPYING also apply to WinSock Chess.
  11.   This module is adapted from GNU Chess.
  12.  
  13.   C source for GNU CHESS
  14.  
  15.   Revision: 1990-09-30
  16.  
  17.   Modified by Daryl Baker for use in MS WINDOWS environment
  18.  
  19.   Based on Ideas and code segments of Charles Petzold from artices in
  20.   MicroSoft Systems Journal.
  21.  
  22.   This file is part of CHESS.
  23.  
  24.   CHESS is distributed in the hope that it will be useful, but WITHOUT ANY
  25.   WARRANTY.  No author or distributor accepts responsibility to anyone for
  26.   the consequences of using it or for whether it serves any particular
  27.   purpose or works at all, unless he says so in writing.  Refer to the CHESS
  28.   General Public License for full details.
  29.  
  30.   Everyone is granted permission to copy, modify and redistribute CHESS, but
  31.   only under the conditions described in the CHESS General Public License.
  32.   A copy of this license is supposed to have been given to you along with
  33.   CHESS so you can know your rights and responsibilities.  It should be in a
  34.   file named COPYING.  Among other things, the copyright notice and this
  35.   notice must be preserved on all copies.
  36. */
  37.  
  38. #define NOATOM 
  39. #define NOCLIPBOARD
  40. #define NOCREATESTRUCT
  41. #define NOFONT
  42. #define NOREGION
  43. #define NOSOUND
  44. #define NOWH
  45. #define NOWINOFFSETS
  46. #define NOCOMM
  47. #define NOKANJI
  48.  
  49. #define STRICT
  50. #include <windows.h>
  51. #include <commdlg.h>
  52. #include <string.h>
  53. #include <stdio.h>
  54.  
  55. #include "chess.h"
  56. #include "color.h"
  57.  
  58. #define CBLACK     RGB(0,0,0)
  59. #define BLUE      RGB(0,0,255)
  60. #define GREEN     RGB(0,255,0)
  61. #define CYAN      RGB(128,255,255)
  62. #define RED       RGB(255,0,0)
  63. #define PINK      RGB(255,0,255)
  64. #define YELLOW    RGB(255,255,0)
  65. #define PALEGRAY  RGB(192,192,192)
  66. #define DARKGRAY  RGB(127,127,127)
  67. #define DARKBLUE  RGB(0,0,128)
  68. #define DARKGREEN RGB(0,128,0)
  69. #define DARKCYAN  RGB(0,255,255)
  70. #define DARKRED   RGB(128,0,0)
  71. #define DARKPINK  RGB(255,0,128)
  72. #define BROWN     RGB(128,128,64)
  73. #define CWHITE     RGB(255,255,255)
  74.  
  75. extern DWORD clrBackGround;
  76. extern DWORD clrBlackSquare;
  77. extern DWORD clrWhiteSquare;
  78. extern DWORD clrBlackPiece;
  79. extern DWORD clrWhitePiece;
  80. extern DWORD clrText;
  81.  
  82. void SetStandardColors (void)
  83. {
  84.    clrBackGround =  BROWN;
  85.    clrBlackSquare = DARKGREEN;
  86.    clrWhiteSquare = PALEGRAY;
  87.    clrBlackPiece  = RED;
  88.    clrWhitePiece  = CWHITE;
  89.    clrText        = CBLACK;
  90. }
  91.  
  92. BOOL ColorDialog ( HWND hWnd, int id )
  93. //-------------------------------------
  94. { CHOOSECOLOR choosecolor;
  95.   DWORD dwCustClrs[16] = { CBLACK,BLUE,GREEN,CYAN,RED,PINK,YELLOW,PALEGRAY,
  96.                            DARKGRAY,DARKBLUE,DARKGREEN,DARKCYAN,DARKRED,
  97.                            DARKPINK,BROWN,CWHITE };
  98.   BOOL bStatus;                         
  99.  
  100.  choosecolor.lStructSize    = sizeof(CHOOSECOLOR);
  101.  choosecolor.hwndOwner      = hWnd;
  102.  choosecolor.hInstance      = NULL;
  103.  choosecolor.rgbResult      = 0L;
  104.  choosecolor.lpCustColors   = (LPDWORD)dwCustClrs;
  105.  choosecolor.Flags          = CC_FULLOPEN;
  106.  choosecolor.lCustData      = 0L;
  107.  choosecolor.lpfnHook       = (FARPROC)NULL;
  108.  choosecolor.lpTemplateName = (LPSTR)NULL;
  109.  
  110.  if ( (bStatus = ChooseColor(&choosecolor)) )
  111.    { switch (id)
  112.       { case IDM_BACKGROUND:
  113.           clrBackGround  = choosecolor.rgbResult;
  114.           break;
  115.  
  116.         case IDM_BLACKSQUARE:
  117.           clrBlackSquare = choosecolor.rgbResult;
  118.           break;
  119.  
  120.         case IDM_WHITESQUARE:
  121.           clrWhiteSquare = choosecolor.rgbResult;
  122.           break;
  123.  
  124.         case IDM_BLACKPIECE:
  125.           clrBlackPiece  = choosecolor.rgbResult;
  126.           break;
  127.  
  128.         case IDM_WHITEPIECE:
  129.           clrWhitePiece  = choosecolor.rgbResult;
  130.           break;
  131.  
  132.         case IDM_TEXT:
  133.           clrText        = choosecolor.rgbResult;
  134.           break; 
  135.       }    
  136.    }
  137.  return bStatus;  
  138. }
  139.  
  140.